/*
 * dTrayIcon.h
 *
 *  Created on: 16.08.2009
 *      Author: index01d
 */

#include "dtranslator.h"

dtranslator::dtranslator(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	setWindowFlags(Qt::FramelessWindowHint);
}

dtranslator::~dtranslator()
{

}

void dtranslator::keyPressEvent(QKeyEvent *event)
{
	int code = event->key();
	switch(code)
	{
	case Qt::Key_Shift:
		emit getTranslate(ui.plainTextEdit->toPlainText());;
		break;
	case Qt::Key_Escape:
		ui.plainTextEdit->setPlainText("");
		hide();
		break;
	}
}

void dtranslator::tReady(const QString& result)
{
	ui.plainTextEdit->setPlainText(result);
}

void dtranslator::needShow(QSystemTrayIcon::ActivationReason reason)
{
	if(reason==QSystemTrayIcon::Trigger)
	{
		setVisible(!isVisible());
		ui.plainTextEdit->setPlainText("");
	}
}
